import wx
import numpy as np
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FiggureCanvas
from matplotlib.figure import Figure


class PlotFrame(wx.Frame):
    def __init__(self, parent, title):
        super(PlotFrame, self).__init__(parent, title=title, size=(800, 600))

        self.figure = Figure()
        self.axes = self.figure.add_subplot(111)

        x = np.linspace(0, 2 * np.pi, 100)
        y = np.cos(x)

        self.axes.plot(x, y)

        self.axes.set_xlabel('X axis')
        self.axes.set_ylabel('Y axis')

        self.axes.set_title('Sine Wave')

        self.canvas = FiggureCanvas(self, -1, self.figure)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.canvas, 1, wx.EXPAND)
        self.SetSizer(sizer)

        self.Bind(wx.EVT_CLOSE, self.OnClose)

    def OnClose(self, event):
        self.Destroy()


if __name__ == '__main__':
    app = wx.App(False)
    frame = PlotFrame(None, '111')
    frame.Show()
    app.MainLoop()
